package dao.pojo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * OrderCommodityInfo entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "order_commodity_info", catalog = "onlinemall")
public class OrderCommodityInfo implements java.io.Serializable {

	// Fields

	private Integer orderCommodityId;
	private Order order;
	private ShelfCommodityInfo shelfCommodityInfo;
	private Integer number;
	private Float price;
	private Set<Comments> commentses = new HashSet<Comments>(0);

	// Constructors

	/** default constructor */
	public OrderCommodityInfo() {
	}

	/** minimal constructor */
	public OrderCommodityInfo(Order order,
			ShelfCommodityInfo shelfCommodityInfo, Integer number, Float price) {
		this.order = order;
		this.shelfCommodityInfo = shelfCommodityInfo;
		this.number = number;
		this.price = price;
	}

	/** full constructor */
	public OrderCommodityInfo(Order order,
			ShelfCommodityInfo shelfCommodityInfo, Integer number, Float price,
			Set<Comments> commentses) {
		this.order = order;
		this.shelfCommodityInfo = shelfCommodityInfo;
		this.number = number;
		this.price = price;
		this.commentses = commentses;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "order_commodity_id", unique = true, nullable = false)
	public Integer getOrderCommodityId() {
		return this.orderCommodityId;
	}

	public void setOrderCommodityId(Integer orderCommodityId) {
		this.orderCommodityId = orderCommodityId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "order_id", nullable = false)
	public Order getOrder() {
		return this.order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "shelf_commodity_id", nullable = false)
	public ShelfCommodityInfo getShelfCommodityInfo() {
		return this.shelfCommodityInfo;
	}

	public void setShelfCommodityInfo(ShelfCommodityInfo shelfCommodityInfo) {
		this.shelfCommodityInfo = shelfCommodityInfo;
	}

	@Column(name = "number", nullable = false)
	public Integer getNumber() {
		return this.number;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}

	@Column(name = "price", nullable = false, precision = 12, scale = 0)
	public Float getPrice() {
		return this.price;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "orderCommodityInfo")
	public Set<Comments> getCommentses() {
		return this.commentses;
	}

	public void setCommentses(Set<Comments> commentses) {
		this.commentses = commentses;
	}

}